package com.muchfish.reactor.api;

import reactor.core.publisher.Flux;

public class ReactorOnErrorContinueExample {
    public static void main(String[] args) {
        Flux<Integer> source = Flux.just(1, 2, 0, 4, 5);

        // 在发生除零错误时继续处理数据流
        source.map(x -> 10 / x)
                .onErrorContinue((error, value) -> {
                    //10/0触发的异常会在最后打印
                    System.err.println("Error: " + error.getMessage() + ", Value: " + value);
                })
                .subscribe(System.out::println);
    }
}
